import Vue from 'vue'
import VueRouter from 'vue-router'
//安装插件
Vue.use(VueRouter)
//创建路由实例
//路由的懒加载
const Home=()=>import('views/home/Home.vue')
const Category=()=>import('views/category/Category.vue')
const ShopCart=()=>import('views/shopcart/ShopCart.vue')
const Profile=()=>import('views/profile/Profile.vue')

//设置路径与组件之间的映射关系
const routes=[
  {
    path:'',
    redirect:'/home'
  },
  {
    path:'/home',
    component:Home
  },
  {
    path:'/category',
    component:Category
  },
  {
    path:'/shopcart',
    component:ShopCart
  },
  {
    path:'/profile',
    component:Profile
  },
]
const router=new VueRouter({
  routes,
  mode:'history'
})
//向外暴露router
export default router